﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.mMall.Public
{
    public partial class mfShowSearchDjackList : msBsc.Cls.mbPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private msBsc.AppLogic.DataAlc.CBizDjackSpecieInfo objVehicleInfo;

        public string GetDjackList()
        {
            objVehicleInfo = new AppLogic.DataAlc.CBizDjackSpecieInfo(HttpUtility.UrlDecode(Request.QueryString.ToString()));


            string strf = objVehicleInfo.dicQuery.ContainsKey("f") ? objVehicleInfo.dicQuery["f"] : "";

            string strf1 = string.IsNullOrEmpty(strf) ? "" : "%" + strf + "%";

            string page = objVehicleInfo.dicQuery.ContainsKey("page") ? objVehicleInfo.dicQuery["page"] : "";

            int pagenum = string.IsNullOrEmpty(page) ? 1 : Convert.ToInt32(page);
            int pagesize = 10;

            using (msBsc.AppLogic.DataAlc.CBizDjackSpecieInfo objCBizDjackSpecieInfo = new AppLogic.DataAlc.CBizDjackSpecieInfo())
            {
                System.Data.DataSet ds = objCBizDjackSpecieInfo.GetDjackList(strf1, pagenum, pagesize);

                int totalPage = 1;

                if (ds.Tables[0].Rows.Count > 0)
                {
                    totalPage = (int)Math.Ceiling(Convert.ToInt32(ds.Tables[0].Rows[0]["TOTAL_DJACK"]) / (double)pagesize);
                }

                string execJsJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "CUSTOMER_REGISTER_ID,CUSTOMER_NICK,CUSTOMER_DEFAULT_PIC,CUSTOMER_BASEINFO_MOBILE,DJACK_INTRODUCE,DNAME,CNAME,CTNAME,TOTAL_DJACK", 1, 200, "");
                //                this.ExecJScript(@"var _html = $('#set_djack_list').html();
                //            laytpl(_html).render(" + execJsJson + @", function (render) {
                //                $('#djack-list-wrap').html(render);
                //            })");

                return "<script type='text/javascript'>doBoundGoodsList(" + execJsJson + ",'','" + strf + "','" + pagenum + "','" + totalPage + "');</script>";
            }

        }

        public override void DoAction()
        {
            if (this.strAction == "GetNextDjack")
            {
                AppendItems();
            }
        }

        private void AppendItems()
        {
            string strf = this.GetParamHtValue("f");
            string currnetPage = this.GetParamHtValue("currentPage");

            string strf1 = string.IsNullOrEmpty(strf) ? "" : "%" + strf + "%";
            int pagenum = string.IsNullOrEmpty(currnetPage) ? 1 : Convert.ToInt32(currnetPage);
            int pagesize = 10;

            using (msBsc.AppLogic.DataAlc.CBizDjackSpecieInfo objCBizDjackSpecieInfo = new AppLogic.DataAlc.CBizDjackSpecieInfo())
            {
                System.Data.DataSet ds = objCBizDjackSpecieInfo.GetDjackList(strf1, pagenum, pagesize);

                int totalPage = 1;

                if (ds.Tables[0].Rows.Count > 0)
                {
                    totalPage = (int)Math.Ceiling(Convert.ToInt32(ds.Tables[0].Rows[0]["TOTAL_DJACK"]) / (double)pagesize);
                }

                string execJsJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "CUSTOMER_REGISTER_ID,CUSTOMER_NICK,CUSTOMER_DEFAULT_PIC,CUSTOMER_BASEINFO_MOBILE,DJACK_INTRODUCE,DNAME,CNAME,CTNAME,TOTAL_DJACK", 1, 200, "");
                //                this.ExecJScript(@"var _html = $('#set_djack_list').html();
                //            laytpl(_html).render(" + execJsJson + @", function (render) {
                //                $('#djack-list-wrap').append(render);
                //            });doBoundGoodsList('','" + strf + "','" + pagenum + "','" + totalPage + "');");
                string queryStr = "11";
                this.ExecJScript("doBoundGoodsList(" + execJsJson + ",'" + queryStr + "','" + strf + "'," + pagenum + "," + totalPage + ")");

            }
        }
    }
}